package runner

import "sync"

const (
	Dev   = "dev"
	Test  = "test"
	Pro   = "pro"
	Debug = "debug"
)

type ServerEnv struct {
	serverNo   string //服务唯一编号
	serverName string //服务名
	mode       string //mode flag
	ip         string //ip
	port       int    //port
	pemPath    string //证书路径,非必须
}


var ins *ServerEnv
var once sync.Once

func GetServerEnv() *ServerEnv {
	once.Do(func() {
		ins = &ServerEnv{}
	})
	return ins
}

func (g *ServerEnv) SetServerNo(no string) *ServerEnv {
	g.serverNo = no
	return g
}

func (g *ServerEnv) SetServerName(serverName string) *ServerEnv {
	g.serverName = serverName
	return g
}

func (g *ServerEnv) SetMode(mode string) *ServerEnv {
	g.mode = mode
	return g
}

func (g *ServerEnv) SetIp(ip string) *ServerEnv {
	g.ip = ip
	return g
}

func (g *ServerEnv) GetIp() string {
	return g.ip
}

func (g *ServerEnv) SetPort(port int) *ServerEnv {
	g.port = port
	return g
}

func (g *ServerEnv) GetPort() int {
	return g.port
}

func (g *ServerEnv) GetMode() string {
	return g.mode
}

func (g *ServerEnv) GetServerNo() string {
	return g.serverNo
}

func (g *ServerEnv) GetServerName() string {
	return g.serverName
}

func (g *ServerEnv) IsDev() bool {
	return g.GetMode() == Dev
}

func (g *ServerEnv) SetPemPath(pemKey string) {
	g.pemPath = pemKey
}

func (g *ServerEnv) GetPemPath() string {
	return g.pemPath
}